<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="main"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head>
    <title>处方划价</title>
    <link th:href="@{/localcss/crmlist.css}" href="../static/localcss/crmlist.css" rel="stylesheet">
    <style>
        .x_nb {
            height: 450px;
        }

        .white_content {
            display: none;
            position: absolute;
            top: 25%;
            left: 20%;
            width: 70%;
            height: 550px;
            padding: 20px;
            border: 1px solid #9CC2CB;
            background-color: white;
            z-index: 1002;
            overflow: auto;
        }

        .white_contentby {
            display: none;
            position: absolute;
            top: 25%;
            left: 35%;
            width: 35%;
            height: 500px;
            padding: 20px;
            border: 1px solid #9CC2CB;
            background-color: white;
            z-index: 1002;
            overflow: auto;
        }

        .white_contentyp {
            display: none;
            position: absolute;
            top: 35%;
            left: 45%;
            width: 14%;
            height: 200px;
            padding: 20px;
            border: 1px solid #9CC2CB;
            background-color: white;
            z-index: 1002;
            overflow: auto;
        }

        #x_page {
            overflow: auto;
        }

        .chatb {
            margin-left: 1280px;
            margin-bottom: 10px;
        }

        .chayp {
            margin-left: 170px;
        }

        .chatbby {
            margin-left: 600px;
            margin-bottom: 10px;
        }

        #div-bur {
            margin-top: 40px;
            margin-left: 240px;
        }

        #div-butyp {
            margin-top: 20px;
            margin-left: 40px;
        }
    </style>
</head>
<body>
<div layout:fragment="content">


    <!--患者信息弹窗-->
    <div id="light" class="white_content">
        <div class="x_nb">
            <div>
                <div class="x_title">
                    <h2>选择病人 <i class="fa fa-user"></i></h2>
                    <div class="chatb">
                        <button onclick="document.getElementById('light').style.display='none';">
                            ✖
                        </button>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    <form>
                        <ul class="x_nbul">
                            <li class="x_nbli">
                                <div class="form-group">
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input name="durgname" type="text" placeholder="请输入要查询的信息"
                                               class="form-control col-md-6 col-xs-12" id="x_text" value="">
                                    </div>
                                    <button type="button" class="btn btn-primary" id="x_but" th:onclick="doSelect(1)">
                                        查询
                                    </button>
                                </div>
                            </li>
                        </ul>
                    </form>
                </div>
            </div>
            <table id="datatable-responsive"
                   class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                   cellspacing="0" width="100%" role="grid"
                   aria-describedby="datatable-responsive_info" style="width: 100%;">
                <thead>
                <tr role="row">
                    <th class="sorting_asc" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="First name: activate to sort column descending"
                        aria-sort="ascending">单据号
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        姓名
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        电话
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        身份证号
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        性别
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        年龄
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        科室
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        医生
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        挂号类别
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        挂号时间
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        挂号费
                    </th>
                    <th class="sorting" tabindex="0"
                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                        aria-label="Last name: activate to sort column ascending">
                        操作
                    </th>
                </tr>
                </thead>
                <tbody id="mobuList">

                </tbody>
            </table>
        </div>
    </div>

    <!--填写病因弹窗-->
    <div id="lightby" class="white_contentby">
        <div class="x_nbby">
            <div>
                <div class="x_title">
                    <h2>填写病因 <i class="fa fa-user"></i></h2>
                    <div class="chatbby">
                        <button onclick="document.getElementById('lightby').style.display='none';">
                            ✖
                        </button>
                    </div>
                    <div class="clearfix"></div>

                </div>
                填写用户病因:
                <div class="x_content">
                    <textarea id="bingyi" style="width: 620px;height: 280px" placeholder="请输入症状病因"></textarea>
                    <div class="form-group" id="div-bur">
                        <button id="send" type="submit" class="btn btn-success">提交</button>
                        <button type="button" class="btn btn-primary" id="back">取消
                        </button>
                    </div>
                </div>
            </div>

        </div>
    </div>

    <!--填写药品数量-->
    <div id="lightyp" class="white_contentyp">
        <div class="x_nbyp">
            <div class="x_title">
                <h2>选择数量 <i class="fa fa-user"></i></h2>
                <div class="chayp">
                    <button onclick="document.getElementById('lightyp').style.display='none';">
                        ✖
                    </button>
                </div>
                <div class="clearfix"></div>
            </div>
            <input type="number" id="num" style="height: 25px;width:200px;margin-top: 15px;" placeholder="请输入数量"
                   autocomplete="off">
            <input type="hidden" id="kunum"><!--药品库存数量-->
            <input type="hidden" id="mename"><!--药品名字-->
            <input type="hidden" id="sellingPrice"><!--药品单价-->
            <span id="uni"></span>
            <div class="x_content">
                <div class="form-group" id="div-butyp">
                    <button id="sendyp" type="button" class="btn btn-success">提交</button>
                    <button type="button" class="btn btn-primary" id="backyp">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>
                            处方划价 <i class="fa fa-user"></i>
                            <small>
                                - 您可以通过搜索或者其他的筛选项对用户的信息进行编辑、删除等管理操作。^_^
                            </small>
                        </h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <form>
                            <input type="hidden" id="reportId"/>
                            <ul>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">姓名</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="rename" id="rename" type="text" onfocus="this.blur()"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">身份证号</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="carid" id="carid" type="text" onfocus="this.blur()"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">性别</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="resex" id="resex" type="text" onfocus="this.blur()"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">年龄</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="age" id="age" type="text" onfocus="this.blur()"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <button id="start" type="button" class="btn btn-primary"
                                            onclick="document.getElementById('light').style.display='block';document.getElementById('lighty').style.display='block';document.getElementById('lightyz').style.display='block';">
                                        开始划价
                                    </button>
                                </li>
                            </ul>
                            <ul>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">科室</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="department" id="rede" type="text" onfocus="this.blur()"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">医生</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="doctorName" id="redo" type="text" onfocus="this.blur()"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">电话</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="phone" id="phone" type="text" onfocus="this.blur()"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">挂号费</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="price" id="price" type="text" onfocus="this.blur()"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <button type="button" class="btn btn-primary"
                                            id="txby">填写病因
                                    </button>
                                </li>
                            </ul>
                        </form>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script layout:fragment="js">

    //判断药品弹窗显示
    if ($("#rename").val() != null && $("#rename").val() != "") {
        document.getElementById('lighty').style.display = 'block';
    }

    //查询药品信息函数
    doSelpharm(1);

    //查询当前患者处方
    function choice(current) {
        var reportId = $("#reportId").val();
        $.ajax({
            type: "get",
            url: "/prescri/selall",
            data: {reportId: reportId, current: current},
            success: function (data) {
                $("#seldrugz").html("");
                $("#x_pagecf").remove();
                var czuo;
                $(data.records).each(function () {
                    if (this.state == 1) {
                        if (this.ostate == 0) {
                            czuo = "项目";
                        } else if (this.mstate == 0) {
                            czuo = "<font color=blue>未缴费</font>"
                        } else if (this.jie == null || d.jie == '') {
                            czuo = '<font color=red>未检查</font>'
                        } else {
                            czuo = "<a class='layui-btn layui-btn-xs' lay-event='look'>查看</a>";
                        }
                    }
                    else {
                        czuo = "<button type='button' class='btn btn -danger'>删除</button>"
                    }
                    i++;
                    //操作列td
                    //操作拼接
                    var atd = " <td>\n" +
                        "                        <div class=\"btn-group\">\n" + czuo +
                        "                        </div>\n" +
                        "                    </td>";
                    //数据拼接
                    var str = "<tr role=\"row\" class=\"odd\" id=\"mobuList1\">" +
                        "<td>" + this.durgname + "</td><td>" + this.durgnum + "</td>" +
                        "<td>" + this.repiceprice + "</td><td>" + this.repicetotal + "</td>" + atd + "</tr>";
                    $("#seldrugz").append(str);

                });
                //分页操作拼接
                var pagepj = "<div id='x_pagecf' class=\"row\">\n" +
                    "                                        <div class=\"col-sm-5\">\n" +
                    "                                            <div class=\"dataTables_info\" id=\"datatable-responsive_info\"\n" +
                    "                                                 role=\"status\" aria-live=\"polite\">共<span\n" +
                    "                                                    th:text=\"${userPager.totalElements }\">" + data.records.length + "</span>条记录\n" +
                    "                                                <span th:text=\"${userPager.number+1 }\">" + data.current + "</span>/<span\n" +
                    "                                                        th:text=\"${userPager.totalPages }\">" + data.pages + "</span>页\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"col-sm-7\">\n" +
                    "                                            <div class=\"dataTables_paginate paging_simple_numbers\"\n" +
                    "                                                 id=\"datatable-responsive_paginate\">\n" +
                    "                                                <ul class=\"pagination\">\n" +
                    "                                                    <li class=\"paginate_button previous\" th:if=\"${" + data.current + " gt 0}\"><a\n" +
                    "                                                            href=\"javascript:page_ypn(1);\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"0\"\n" +
                    "                                                            tabindex=\"0\">首页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button \" th:if=\"${" + data.current + " gt 0}\"><a\n" +
                    "                                                            href=\"javascript:page_ypn(" + (data.current - 1) + ");\"\n" +
                    "                                                            th:onclick=\"'javascript:page_ypn(" + (data.current - 1) + ");'\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                    "                                                            tabindex=\"0\">上一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button \"\n" +
                    "                                                        th:if=\"${(" + (data.current) + ") lt " + data.pages + "}\"><a\n" +
                    "                                                            href=\"javascript:page_ypn(" + (data.current + 1) + ");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                    "                                                            tabindex=\"0\">下一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button next\"\n" +
                    "                                                        th:if=\"${(" + (data.current) + ") lt " + data.pages + "}\"><a\n" +
                    "                                                            href=\"javascript:page_ypn(" + data.pages + ");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"7\"\n" +
                    "                                                            tabindex=\"0\">最后一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                </ul>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                    </div>";
                $("#datatable-responsive1z").after(pagepj);
            }
        })
    }

    //添加患者处方
    function addchoice(obj) {
        var reid = $("#reportId").val();
        //显示处方弹窗
        document.getElementById('lightyz').style.display = 'block';
        if (reid <= 0) {
            alert("请先选择患者");
        } else {
            //进入查询患者的有没有写病因
            $.post("/prescri/selbing", {"reid": reid}, function (obj) {
                if (obj == '') {
                    alert("请先填写病因");
                } else {
                    document.getElementById('lightyp').style.display = 'block';
                }
            });
            console.info(obj.unitname);
            console.info(obj.drugstorenum);
            console.info(obj.pharmacyName);
            console.info(obj.sellingPrice);
            $("#uni").text(obj.unitname);//单位
            $("#kunum").val(obj.drugstorenum);//库存
            $("#mename").val(obj.pharmacyName);//药品名字
            $("#sellingPrice").val(obj.sellingPrice);//药品单价
        }
    }

    //点击添加药品数量的提交按钮
    $("#sendyp").click(function () {
        //获取文本框的数量
        var num = $("#num").val();
        //获取用户挂号id
        var reid = $("#reportId").val();
        //获取库存
        var kunum = $("#kunum").val();
        //获取药品的名字
        var mename = $("#mename").val();
        //获取药品单价
        var sellingPrice = $("#sellingPrice").val();
        //小计
        var price = num * sellingPrice
        //判断添加数量的文本框是否有值或者为0如果成立提示
        if (num == "" || num == 0 || num < 0) {
            alert("请输入正确的药品的数量");
        } else if (Number(num) > Number(kunum)) {//判断输入的数量是否大于库存要是大于提示
            alert("对不起当前库存不足");
        } else if (reid == "") {//判断是否选中用户如果没有选中用户着提示
            alert("请选择患者");
        } else {
            $.post("/prescri/selchu", {"reid": reid, "mename": mename}, function (obj) {
                alert("查询有没有" + obj);
                //如果为零表示没有这个药则添加
                if (obj == 0) {
                    $.post("/prescri/addchu", {
                        "reportId": reid,
                        "durgname": mename,
                        "durgnum": num,
                        "repiceprice": sellingPrice,
                        "repicetotal": price,
                        "drugstorenum": num
                    }, function (obj) {
                        alert("添加成功");
                        choice(1);
                        document.getElementById('lightyp').style.display = 'none';
                    })
                } else {
                    //如果有则修改数量
                    $.post("/prescri/updchu", {
                        "reportId": reid,
                        "durgname": mename,
                        "durgnum": num,
                        "repicetotal": price,
                        "drugstorenum": num
                    }, function (obj) {
                        alert("添加成功");
                        choice(1);
                        document.getElementById('lightyp').style.display = 'none';
                    })
                }
            })
        }
    })
    //点击添加药品的取消按钮
    $("#clo").click(function () {
        //关闭弹出的窗口
        $("#num").val("");
        document.getElementById('lightyp').style.display = 'none';
    });
    //点击填写病因
    $("#txby").click(function () {
        var reid = $("#reportId").val();
        if (reid <= 0) {
            alert("请先选择患者");
        } else {
            document.getElementById('lightby').style.display = 'block';
            $.post("/prescri/selbing", {"reid": reid}, function (data) {
                $("#bingyi").val(data);
            });
        }
    })
    //点击病因提交按钮
    $("#send").click(function () {
        var reid = $("#reportId").val();
        var bing = $("#bingyi").val();
        $.post("/prescri/addbing", {"reid": reid, "bing": bing}, function (obj) {
            if (obj > 0) {
                alert("添加成功");
                document.getElementById('lightby').style.display = 'none';
            } else {
                alert("添加失败");
            }
        });
    })
    //点击病因取消按钮
    $("#back").click(function () {
        $("#bingyi").val("");
        document.getElementById('lightby').style.display = 'none';
    })


    //查询所有药品
    function doSelpharm(current) {
        //药品名称
        var pharmacyName = $("#pharmacyName").val();
        $.ajax({
            type: "get",
            url: "/prescri/seldrug",
            data: {"pharmacyName": pharmacyName, "current": current},
            success: function (data) {
                var obj;
                $("#x_pagey").remove();
                $("#seldrug").html("");
                $(data.records).each(function (index) {
                    obj = JSON.stringify(data.records[index]);
                    //操作列td
                    //操作拼接
                    var atd = " <td>\n" +
                        "                        <div class=\"btn-group\">\n" +
                        "                                <a class=\"btn btn-danger\"\n" +
                        "                                       data-toggle=\"tooltip\" data-placement=\"top\" title=\"\"\n" +
                        "                                       data-original-title=\"选择\" onclick='addchoice(" + obj + ")'>选择</a>\n" +
                        "                        </div>\n" +
                        "                    </td>";
                    //数据拼接
                    var str = "<tr role=\"row\" class=\"odd\" id=\"mobuList1\">" +
                        "<td>" + this.pharmacyName + "</td><td>" + this.drugstorenum + "</td>" +
                        "<td>" + this.unitname + "</td><td>" + this.sellingPrice + "</td>" + atd + "</tr>";
                    $("#seldrug").append(str);
                });
                //分页操作拼接
                var pagepj = "<div id='x_pagey' class=\"row\">\n" +
                    "                                        <div class=\"col-sm-5\">\n" +
                    "                                            <div class=\"dataTables_info\" id=\"datatable-responsive_info\"\n" +
                    "                                                 role=\"status\" aria-live=\"polite\">共<span\n" +
                    "                                                    th:text=\"${userPager.totalElements }\">" + data.records.length + "</span>条记录\n" +
                    "                                                <span th:text=\"${userPager.number+1 }\">" + data.current + "</span>/<span\n" +
                    "                                                        th:text=\"${userPager.totalPages }\">" + data.pages + "</span>页\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"col-sm-7\">\n" +
                    "                                            <div class=\"dataTables_paginate paging_simple_numbers\"\n" +
                    "                                                 id=\"datatable-responsive_paginate\">\n" +
                    "                                                <ul class=\"pagination\">\n" +
                    "                                                    <li class=\"paginate_button previous\" th:if=\"${" + data.current + " gt 0}\"><a\n" +
                    "                                                            href=\"javascript:page_ypn(1);\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"0\"\n" +
                    "                                                            tabindex=\"0\">首页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button \" th:if=\"${" + data.current + " gt 0}\"><a\n" +
                    "                                                            href=\"javascript:page_ypn(" + (data.current - 1) + ");\"\n" +
                    "                                                            th:onclick=\"'javascript:page_ypn(" + (data.current - 1) + ");'\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                    "                                                            tabindex=\"0\">上一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button \"\n" +
                    "                                                        th:if=\"${(" + (data.current) + ") lt " + data.pages + "}\"><a\n" +
                    "                                                            href=\"javascript:page_ypn(" + (data.current + 1) + ");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                    "                                                            tabindex=\"0\">下一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button next\"\n" +
                    "                                                        th:if=\"${(" + (data.current) + ") lt " + data.pages + "}\"><a\n" +
                    "                                                            href=\"javascript:page_ypn(" + data.pages + ");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"7\"\n" +
                    "                                                            tabindex=\"0\">最后一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                </ul>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                    </div>";
                $("#datatable-responsivey").after(pagepj);
            }
        });
    }

    //填充选中患者信息到页面
    function aa(obj) {
        $("#reportId").val(obj.reportId)
        $("#rename").val(obj.reportName)
        $("#resex").val(obj.sex)
        $("#age").val(obj.age)
        $("#rede").val(obj.department);
        $("#redo").val(obj.doctorName);
        $("#carid").val(obj.carid);
        $("#phone").val(obj.phone);
        $("#price").val(obj.price);
        choice(1);
        document.getElementById('light').style.display = 'none';
    }

    //模糊查询ajax方法
    function doSelect(current) {
        //姓名
        var durgname = $("#x_text").val();
        $.ajax({
            type: "get",
            url: "/prescri/mobuList",
            data: {"durgname": durgname, "current": current},
            success: function (data) {
                var obj;
                $("#x_page").remove();
                $("#mobuList").html("");
                $(data.records).each(function (index) {
                    obj = JSON.stringify(data.records[index]);
                    //操作列td
                    //操作拼接
                    var atd = " <td>\n" +
                        "                                                <div class=\"btn-group\">\n" +
                        "                                                    <span class=\"btn btn-danger\" onclick='aa(" + obj + ")'> 选择 </span>\n" +
                        "                                                </div>\n" +
                        "                                            </td>";
                    //数据拼接
                    var str = "<tr role=\"row\" class=\"odd\" id=\"mobuList1\">" +
                        "<td>" + this.reportId + "</td><td>" + this.reportName + "</td>" +
                        "<td>" + this.phone + "</td><td>" + this.carid + "</td>" +
                        "<td>" + this.sex + "</td><td>" + this.age + "</td>" +
                        "<td>" + this.department + "</td><td>" + this.doctorName + "</td>" +
                        "<td>" + this.type + "</td><td>" + this.time + "</td>" +
                        "<td>" + this.price + "</td>" + atd + "</tr>";
                    $("#mobuList").append(str);
                });
                //分页操作拼接
                var pagepj = "<div id='x_page' class=\"row\">\n" +
                    "                                        <div class=\"col-sm-5\">\n" +
                    "                                            <div class=\"dataTables_info\" id=\"datatable-responsive_info\"\n" +
                    "                                                 role=\"status\" aria-live=\"polite\">共<span\n" +
                    "                                                    th:text=\"${userPager.totalElements }\">" + data.records.length + "</span>条记录\n" +
                    "                                                <span th:text=\"${userPager.number+1 }\">" + data.current + "</span>/<span\n" +
                    "                                                        th:text=\"${userPager.totalPages }\">" + data.pages + "</span>页\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"col-sm-7\">\n" +
                    "                                            <div class=\"dataTables_paginate paging_simple_numbers\"\n" +
                    "                                                 id=\"datatable-responsive_paginate\">\n" +
                    "                                                <ul class=\"pagination\">\n" +
                    "                                                    <li class=\"paginate_button previous\" th:if=\"${" + data.current + " gt 0}\"><a\n" +
                    "                                                            href=\"javascript:page_nav(1);\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"0\"\n" +
                    "                                                            tabindex=\"0\">首页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button \" th:if=\"${" + data.current + " gt 0}\"><a\n" +
                    "                                                            href=\"javascript:page_nav(" + (data.current - 1) + ");\"\n" +
                    "                                                            th:onclick=\"'javascript:page_nav(" + (data.current - 1) + ");'\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                    "                                                            tabindex=\"0\">上一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button \"\n" +
                    "                                                        th:if=\"${" + (data.current) + " lt " + data.pages + "}\"><a\n" +
                    "                                                            href=\"javascript:page_nav(" + (data.current + 1) + ");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                    "                                                            tabindex=\"0\">下一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button next\"\n" +
                    "                                                        th:if=\"${" + (data.current) + " lt " + data.pages + "}\"><a\n" +
                    "                                                            href=\"javascript:page_nav(" + data.pages + ");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"7\"\n" +
                    "                                                            tabindex=\"0\">最后一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                </ul>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                    </div>";
                $("#datatable-responsive").after(pagepj);
            }
        });
    }
</script>
</html>